import { useGetState } from '@/hooks/useRedux'
import { changeLangauge, LanguageEnum, SettingInitialState } from '@/redux/slices/setting.slice'
import { Select } from 'antd'
import { useDispatch } from 'react-redux'

// 语言切换下拉框
export default function LanguageChoice() {
    const setting = useGetState<SettingInitialState>('setting')
    const dispatch = useDispatch()

    // 切换语言
    const handleChange = (value: LanguageEnum) => {
        dispatch(changeLangauge(value))
    }

    return (
        <Select value={setting.langauge} style={{ width: 90 }} onChange={handleChange}>
            <Select.Option value={LanguageEnum.ZN_CH}>中文</Select.Option>
            <Select.Option value={LanguageEnum.ZN_HK}>繁体(港)</Select.Option>
            <Select.Option value={LanguageEnum.ZH_TW}>繁体(台)</Select.Option>
            <Select.Option value={LanguageEnum.EN_US}>英语</Select.Option>
        </Select>
    )
}
